Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally delete points layers after finishing alignment #88

Merged
merged 10 commits into from
Dec 12, 2023

Conversation

andreasmarnold
Copy link
Contributor

Addresses issue #9

I did not write any tests for this since I didn't really know how (close_affinder also doesn't seem to get tested)

Also, this option has the same issue as described in #29

@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (927b50f) 90.66% compared to head (4156cb1) 93.52%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #88      +/-   ##
==========================================
+ Coverage   90.66%   93.52%   +2.86%     
==========================================
  Files           7        7              
  Lines         257      278      +21     
==========================================
+ Hits          233      260      +27     
+ Misses         24       18       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@jni jni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andreasmarnold! I think that it's actually much simpler than expected. 😅

Re testing, I think you can just call the widget again, and that will trigger closing!

@@ -136,6 +144,7 @@ def start_affinder(
moving_points: Optional['napari.layers.Points'] = None,
model: AffineTransformChoices,
output: Optional[pathlib.Path] = None,
keep_pts: bool = False,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reverse this, call it delete_points_when_done. Label: "Delete points layers when done." Tooltip: "If ticked, the points layers used in alignment will be deleted when clicking 'Finish'."

Comment on lines 196 to 199
remove_pts_layers.viewer.bind(viewer)
remove_pts_layers.layers.bind(points_layers)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realised that it was silly to use magicgui for this at all — functools.partial will do the job:

import functools

...

def remove_layers(viewer, layers):
    for layer in layers:
        viewer.layers.remove(layer)

...

remove_points_layers = functools.partial(
        remove_layers, viewer, [points_layers]
        )

...

else:
    remove_points_layers()

I'm pretty sure you can do the same thing with close_affinder 🤦, if you want to close #29 with a different PR... 😅

Copy link
Owner

@jni jni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gdi, wrong button again 😅

@jni
Copy link
Owner

jni commented Dec 8, 2023

Thanks for the update @andreasmarnold! Let me know if you want me to wrap up this PR myself.

@andreasmarnold
Copy link
Contributor Author

Hi @jni,
It would be great if you could have a look at implementing functools as you suggested.
I've not worked with it before and don't really have lots of free time to familiarize myself with it before Christmas.
Probably much more efficient if you do it ....

Thx!

@jni jni changed the title Delete pts layers Optionally delete points layers after finishing alignment Dec 12, 2023
@jni jni merged commit 0fd9797 into jni:main Dec 12, 2023
10 checks passed
@jni
Copy link
Owner

jni commented Dec 12, 2023

Whoop whoop! Actually the functools.partial method was a bit trickier than I expected so I'm glad I didn't leave you to finish it on your own. 😂 Remember to git switch main and git pull upstream main to get up to date with this change! 😊

@andreasmarnold
Copy link
Contributor Author

andreasmarnold commented Dec 12, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants